Skip to content

adding rabbitmq container - #51

Closed
dabrign wants to merge 14 commits into
testcontainers:masterfrom
dabrign:addinrabbitmq
Closed

dabrign wants to merge 14 commits into
testcontainers:masterfrom
dabrign:addinrabbitmq

Conversation

@dabrign

@dabrign dabrign commented Jan 10, 2020

Copy link
Copy Markdown
Contributor

This pull request is meant to add rabbitmq to this suite. However, it is still a 'work-in-progress', but I would like to have some opinions on this implementation and, specifically, on how to write an efficient test.

More in details, it is well known that the decorator @wait_container_is_ready just wait if is possible to 'talk' with the container and it does not wait until the application is ready to receive commands.
For that reason, in order to successfully exit the test, I had to add a (very inelegant) sleep to wait the additional time needed for the application inside the container to be ready.

Anyone experienced similar problem?
How did you solve it?
Thanks

@tillahoffmann tillahoffmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Added some comments inline.

return parameters

@wait_container_is_ready()
def declare_queue(self, queue):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a duplicate (in terms of signature) of the function in line 48. Should this be removed?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to the logic - this method is supposed to declare multiple queues

Comment thread tests/test_rabbitmq.py Resolved
Comment thread tests/test_rabbitmq.py Resolved
Comment thread tests/test_rabbitmq.py Outdated
import pika

def test_declare_queue():
rabbitmq_container = RabbitmqContainer("rabbitmq:3-management")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can we not use the standard rabbitmq:lastest tag here?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it does not work with rabbitmq:latest :)

Comment thread testcontainers/rabbitmq.py Resolved
Comment thread tests/test_rabbitmq.py Resolved
@dabrign
dabrign marked this pull request as ready for review December 7, 2020 21:13
@vryazanov

Copy link
Copy Markdown

@dabrign any plans to finish it? if no - I'll take care of this pr


@wait_container_is_ready()
def declare_vhost(self, vhost):
cmd = "rabbitmqadmin declare exchange vhost={} type={}".format(vhost)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type is missing

RABBITMQ_DEFAULT_PASS = os.environ.get("RABBITMQ_DEFAULT_PASS", "guest")
SERVICE_STARTED = r"Server startup complete;"

def __init__(self, image="rabbitmq:latest"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rabbitmq:latest does not have rabbitmqadmin, so all methods below which are using it do not work

@wait_container_is_ready()
def get_connection_parameters(self):
credentials = pika.PlainCredentials(self.RABBITMQ_DEFAULT_USER, self.RABBITMQ_DEFAULT_PASS)
parameters = pika.ConnectionParameters(self.get_container_host_ip(), self.port_to_expose,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.port_to_expose -> self.get_exposed_port(self.port_to_expose)

self.with_exposed_ports(self.port_to_expose)
self.queues = list()

def _configure(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is not called at all, nowhere

@yakimka

yakimka commented Apr 1, 2022

Copy link
Copy Markdown
Contributor

RabbitMQ support was added in #162

@yakimka yakimka closed this Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants